//2917.找出数组中的K-or值
//https://leetcode.cn/problems/find-the-k-or-of-an-array/?envType=daily-question&envId=2024-03-06
class Solution {
public:
    int findKOr(vector<int>& nums, int k) {
        int n = nums.size();
        int ret = 0;
        for(int i = 0;i<32;++i)
        {
            int cnt = k;
            for(int num:nums)
            {
                long long pown = (long long)pow(2,i);
                cnt -= ((pown & num) == pown);
            }
            if(cnt <= 0) ret += (int)pow(2,i);
        }
        return ret;
    }
};